package cn.edu.scau.dao;

import cn.edu.scau.entity.NursingContent;


import org.apache.ibatis.jdbc.SQL;

public class NursingContentSqlProvider {

    public String insertSelective(NursingContent record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("nursingcontent");
        
        if (record.getNursingcontentid() != null) {
            sql.VALUES("nursingContentID", "#{nursingcontentid,jdbcType=INTEGER}");
        }
        
        if (record.getNursingcontentprojectname() != null) {
            sql.VALUES("nursingContentProjectName", "#{nursingcontentprojectname,jdbcType=VARCHAR}");
        }
        
        if (record.getNursingcontentprice() != null) {
            sql.VALUES("nursingContentPrice", "#{nursingcontentprice,jdbcType=DECIMAL}");
        }
        
        if (record.getNursingcontentdescription() != null) {
            sql.VALUES("nursingContentDescription", "#{nursingcontentdescription,jdbcType=VARCHAR}");
        }
        
        if (record.getNursingcontentstatus() != null) {
            sql.VALUES("nursingContentStatus", "#{nursingcontentstatus,jdbcType=BIT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(NursingContent record) {
        SQL sql = new SQL();
        sql.UPDATE("nursingcontent");
        
        if (record.getNursingcontentprojectname() != null) {
            sql.SET("nursingContentProjectName = #{nursingcontentprojectname,jdbcType=VARCHAR}");
        }
        
        if (record.getNursingcontentprice() != null) {
            sql.SET("nursingContentPrice = #{nursingcontentprice,jdbcType=DECIMAL}");
        }
        
        if (record.getNursingcontentdescription() != null) {
            sql.SET("nursingContentDescription = #{nursingcontentdescription,jdbcType=VARCHAR}");
        }
        
        if (record.getNursingcontentstatus() != null) {
            sql.SET("nursingContentStatus = #{nursingcontentstatus,jdbcType=BIT}");
        }
        
        sql.WHERE("nursingContentID = #{nursingcontentid,jdbcType=INTEGER}");
        
        return sql.toString();
    }
    
    public String findByNursingcontentprojectname(String nursingcontentprojectname) {
    	SQL sql = new SQL();
    	sql.SELECT("nursingContentID, nursingContentProjectName, nursingContentPrice, nursingContentDescription, nursingContentStatus");
    	sql.FROM("nursingcontent");
    	if(nursingcontentprojectname!=null) {
    		sql.WHERE(" nursingContentProjectName like concat('%',#{nursingcontentprojectname},'%')");
    	}
    	return sql.toString();
    }
}